package com.huawei.appgallery.agwebview.view;

import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import com.huawei.appgallery.agwebview.api.ui.IWebViewActivityProtocol;
import com.huawei.appgallery.agwebview.api.ui.IWebViewActivityResult;
import com.huawei.appgallery.foundation.ui.framework.activity.AbstractBaseActivity;
import com.huawei.hmf.annotation.ActivityDefine;
import o.azh;
import o.azq;
import o.bam;
import o.bba;
import o.dgh;
import o.djk;
import o.dof;
import o.ean;
import o.fiv;

@ActivityDefine(alias = "webview_activity", protocol = IWebViewActivityProtocol.class, result = IWebViewActivityResult.class)
public class WebViewActivity extends AbstractBaseActivity {
    private long ˊॱ;
    private String ˋॱ = "";
    protected fiv ˏॱ = fiv.ॱ(this);
    private azq ॱˊ;

    public void onCreate(Bundle bundle) {
        djk.ˋ().ˎ(WebViewActivity.class);
        bba.ॱ().ˎ(this);
        super.onCreate(bundle);
        IWebViewActivityProtocol iWebViewActivityProtocol = (IWebViewActivityProtocol) this.ˏॱ.ॱ();
        if (iWebViewActivityProtocol == null) {
            azh.ˏ.ˊ("WebViewActivity", "webviewActivityProtocol is null");
            finish();
            return;
        }
        this.ॱˊ = ˊ(iWebViewActivityProtocol);
        if (this.ॱˊ == null) {
            azh.ˏ.ˊ("WebViewActivity", "webviewDelegate is null,uri=" + this.ˋॱ);
            return;
        }
        String url = iWebViewActivityProtocol.getUrl();
        if (dof.ˋ(url)) {
            finish();
        } else if (this.ॱˊ.ˊ(this, iWebViewActivityProtocol)) {
            this.ॱˊ.ॱ(this, iWebViewActivityProtocol);
            if (ᐝ()) {
                this.ॱˊ.ˏ((Context) this, iWebViewActivityProtocol);
                this.ॱˊ.ʽ(url);
                this.ॱˊ.ॱ((Activity) this);
                return;
            }
            finish();
        } else {
            finish();
        }
    }

    protected azq ˊ(IWebViewActivityProtocol iWebViewActivityProtocol) {
        if (iWebViewActivityProtocol == null) {
            azh.ˏ.ˊ("WebViewActivity", "WebviewActivityProtocol is null");
            return null;
        }
        this.ˋॱ = iWebViewActivityProtocol.getUri();
        if (!dof.ˋ(this.ˋॱ)) {
            return bam.INSTANCE.ˋ(this.ˋॱ);
        }
        azh.ˏ.ˊ("WebViewActivity", "uri is blank");
        return null;
    }

    protected boolean ᐝ() {
        try {
            View inflate = getLayoutInflater().inflate(this.ॱˊ.ʻ(), null);
            setContentView(inflate);
            this.ॱˊ.ˎ(inflate);
            return true;
        } catch (Throwable e) {
            azh.ˏ.ˊ("WebViewActivity", "SetContentView appends InflateException!", e);
            return false;
        }
    }

    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (i != 4) {
            return super.onKeyDown(i, keyEvent);
        }
        if (this.ॱˊ != null) {
            this.ॱˊ.ᐝ();
        }
        return true;
    }

    public void onDestroy() {
        bba.ॱ().ˊ(this);
        super.onDestroy();
        if (this.ॱˊ != null) {
            this.ॱˊ.ʽ();
        }
    }

    public void finish() {
        super.finish();
    }

    public void onResume() {
        super.onResume();
        if (this.ॱˊ != null) {
            this.ॱˊ.ॱˋ();
        }
        this.ˊॱ = dgh.ॱ();
    }

    public void ʼ() {
    }

    public void S_() {
    }

    public void onPause() {
        super.onPause();
        if (this.ॱˊ != null) {
            this.ॱˊ.ˈ();
        }
        IWebViewActivityProtocol iWebViewActivityProtocol = (IWebViewActivityProtocol) this.ˏॱ.ॱ();
        if (iWebViewActivityProtocol != null) {
            ean.ˏ(iWebViewActivityProtocol.getStayTimeKey(), System.currentTimeMillis() - this.ˊॱ, iWebViewActivityProtocol.getUri());
        }
    }

    public void onConfigurationChanged(Configuration configuration) {
        super.onConfigurationChanged(configuration);
        if (this.ॱˊ != null) {
            this.ॱˊ.ˎ(configuration);
            invalidateOptionsMenu();
        }
    }

    public void onRequestPermissionsResult(int i, String[] strArr, int[] iArr) {
        if (this.ॱˊ == null || !this.ॱˊ.ˋ(i, strArr, iArr)) {
            super.onRequestPermissionsResult(i, strArr, iArr);
        }
    }

    public void ˊॱ() {
        if (this.ॱˊ != null && this.ॱˊ.ʼ()) {
            super.ˊॱ();
        }
    }
}
